package com.zjh.notification.model;

import com.jfinal.kit.JMap;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.zjh.notification.model.base.BaseNotification;
import com.zjh.notification.model.page.NotificationPage;

import java.util.List;

/**
 * Created by zZz on 2017/4/25 0025.
 */
public class Notification extends BaseNotification<Notification> {
    public static Notification dao = new Notification();

    /**
     * 获取通知公告列表
     *
     * @param beginTime|开始时间|String|选填
     * @param endTime|结束时间|String|选填
     * @param title|标题|String|选填
     * @param type|类型|Integer|选填
     * @title 获取通知公告列表
     */
    public List<Notification> getNotifications(String beginTime,String endTime,String title,String type)
    {
        JMap map = JMap.create("beginTime",beginTime).set("endTime",endTime).set("title",title).set("type",type);
        return find(getSqlPara("Notification.getNotifications",map));
    }

    public Page<Notification> paginate(NotificationPage notificationPage)
    {
        Record record = notificationPage.toRecord();
        return paginate(notificationPage.getPageNumber(), notificationPage.getPageSize(), getSql("Notification.getNoForPage"), getSql("Notification.sqlExceptSelect", record.getColumns()), record.getColumnValues());
    }

}
